package gui.swing;

import exception.MyException;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

//主窗口
public class TestDialog extends JFrame {

    public TestDialog(){
        this.setVisible(true);
        this.setBounds(100,100,700,500);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

        //JFrame 放东西，容器
        Container container = this.getContentPane();

        //绝对布局
        container.setLayout(null);

        JButton jButton = new JButton("点击弹出对话框");
        jButton.setBounds(30,30,200,50);
        container.add(jButton);

        //点击按钮弹出弹窗
        jButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //弹窗
                new MyDialog();
            }
        });
    }

    public static void main(String[] args) {
        new TestDialog();
    }
}

//弹窗
class MyDialog extends JDialog{
    public MyDialog(){
        this.setVisible(true);
        this.setBounds(100,100,500,500);
//        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

        Container contentPane = this.getContentPane();
        contentPane.setLayout(null);

        contentPane.add(new JLabel("zsh1231231"));

    }
}